# -*- coding: utf-8 -*-
from datetime import datetime,timedelta
from dateutil.relativedelta import relativedelta 
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT

def get_next_date(datestr,addtype,addcount):
    """
    根据参数获取下个日期
    @addtype month or days
    @datestr date string
    """
    if addtype=='month':
        return get_date_by_addmonth(datestr,addcount)
    elif addtype=='day':
        return get_date_by_addday(datestr,addcount)
    return datestr

def get_date_by_addday(datestr,days):
    d = datetime.strptime(datestr,DATE_FORMAT)
    nextday = d + relativedelta(days=+1)
    return datetime.strftime(nextday,DATE_FORMAT),

def get_date_by_addmonth(datestr,month):
    d = datetime.strptime(datestr,DATE_FORMAT)
    nextday = d + relativedelta(months=+1)
    return datetime.strftime(nextday,DATE_FORMAT),
